package org.eenie.commonlib.ui.arch.fragment;


import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class LazyFragmentAdapter extends FragmentPagerAdapter {

    List<Fragment> mFragments = new ArrayList<>();


    public LazyFragmentAdapter(FragmentManager fm) {
        super(fm);
        for (int i = 0; i < 2; i++) {
            mFragments.add(TestLazyFragment.newInstance("pos = "+ i));
        }
    }

    @Override
    public Fragment getItem(int i) {
        return mFragments.get(i);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }


    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return "F" + position;
    }
}
